import 'package:p_location/utils/string_util.dart';

class ParseParamsUtil {
  static Map<String, dynamic> parse(String url) {
    if (StringUtil.isNotEmpty(url) && url.contains("?")) {
      int index = url.indexOf("?", 0);
      String params = url.substring(index+1);
      if (StringUtil.isNotEmpty(params)) {
        List<String> pairs = params.split("&");
        if (pairs != null && pairs.length > 0) {
          Map<String, dynamic> params = {};
          pairs.forEach((e) {
            List<String> keyValue = e.split("=");
            params[keyValue[0]] = keyValue[1];
          });
          return params;
        }
      }
    }
    return {};
  }
}
